package com.hifar.test.equipsensor.mapper;

import java.util.List;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hifar.test.equipsensor.pojo.EquipClassifySearchVo;
import com.hifar.test.equipsensor.pojo.EquipSensorSearchVo;
import com.hifar.test.equipsensor.pojo.HfResEquipSensor;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
/**
 * <p>
 * 资源-设备传感器-关系表 mapper接口
 * </p>
 *
 * @author wangkepeng
 * @since 2024-12-11 14:13:02
 */
@Mapper
public interface HfResEquipSensorMapper extends BaseMapper<HfResEquipSensor> {


	Page<EquipSensorSearchVo> entityVoPage(Page<EquipSensorSearchVo> rowPage, @Param(Constants.WRAPPER) QueryWrapper wrapper);

	@Select(" select * from (select t.* ,p.equip_name,p.equip_code,p.EQUIP_MODEL, "
			+ " s.sensor_name,s.sensor_code from HF_RES_EQUIP_SENSOR t left join hf_res_equip p "
			+ " on t.equip_id=p.id left join hf_res_sensor s "
			+ " on s.id=t.sensor_id ) x   ${ew.customSqlSegment} ")
	public List<EquipSensorSearchVo> listEntityVo(@Param(Constants.WRAPPER) QueryWrapper wrapper);

	@Select("select * from HF_RES_EQUIP_UNIT   ${ew.customSqlSegment} ")
	Page<EquipClassifySearchVo> entityEquipClassifyVoPage(Page<EquipClassifySearchVo> rowPage, @Param(Constants.WRAPPER) QueryWrapper wrapper);

	@Select("select * from (SELECT ITEM_KEY AS ID,'0' AS PID,ITEM_VALUE AS NAME, '1' AS DATA_TYPE,0 as DEL_FLAG  FROM base_sys_dict_item WHERE DICT_CODE='equip_classify_type' "
			+ "  union all   "
			+ "select ID,CLASSIFY_TYPE_CODE AS PID ,EQUIP_NAME AS NAME, '2' AS DATA_TYPE,0 as DEL_FLAG  from HF_RES_EQUIP where DEL_FLAG=0  "
			+ ") x   ${ew.customSqlSegment}  ")
	List<EquipClassifySearchVo> listEntityEquipClassifyVo(@Param(Constants.WRAPPER) QueryWrapper wrapper);


}